<?php

namespace app\models\factory;

use think\facade\Db;
use think\Model;

class Record extends Model
{
    protected $name = 'record';
    protected $pk   = 'id';

    public static function add($field)
    {
        $day = strtotime(date('Y-m-d H:00:00'));
        $record = Db::name('record')->where(['hour' => $day])->find();
        if (!$record) {
            Db::name('record')->insert(['hour' => $day]);
        }
        Db::name('record')->where(['hour' => $day])->inc($field)->update();
        return;
    }

}
